package redis_client

import (
	"gin-study/config"
	"github.com/go-redis/redis/v8"
)

var raw *redis.Client
var cache *redis.Client
var queue *redis.Client

//初始化原生redis客户端
func init() {
	raw = newClient(0)
	cache = newClient(1)
	queue = newClient(2)
}

//获取原生redis操作客户端
func Raw() *redis.Client {
	return raw
}

//获取原生redis操作客户端
func Cache() *redis.Client {
	return cache
}

//获取原生redis操作客户端
func Queue() *redis.Client {
	return queue
}

//获取一个Redis客户端
func newClient(db int) *redis.Client {
	client := redis.NewClient(&redis.Options{
		Addr:     config.Redis.Host,
		Password: config.Redis.Password,
		DB:       db,
	})
	return client
}
